const app = getApp()
const request = require('../../utils/https.js')
var userId, orderId;

Page({

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    console.log('options==>', options)
    const that = this;
    userId = wx.getStorageSync('userId');
    orderId = options.orderid
    //退换货详情states: 4 进行中 6不通过 7已通过 type:0换货  1退货
    request._get(getApp().Api_url + 'userOrder/getBackOrder', {
      userId: userId,
      orderId: orderId
    }, function(res) {


      if (res.data.success == true) {
        let dataAfter = res.data.data;
        that.setData({
          dataAfter: dataAfter
        })
      }
    }, function() {});
  },
  //撤销
  onUndo() {
    //退换货详情states: 4 进行中 6不通过 7已通过 type:0换货  1退货
    request._get(getApp().Api_url + 'userOrder/undoAfterOrder', {
      userId: userId,
      orderId: orderId
    }, function(res) {

      if (res.data.success == true) {
        wx.showToast({
          icon:'none',
          title: '撤销申请成功',
        })
        wx.redirectTo({
          url: '/pages/my_order/my_order',
        })
      }
    }, function() {});
  },
  //重新申请
  onAgain() {
    wx.redirectTo({
      url: '/pages/after_sales/after_sales?orderId=' + orderId,
    })
  },

})